package com.gp.gback.system;

import com.gp.gback.system.common.util.SpringUtils;
import com.gp.gback.system.config.DatabaseConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.filter.CharacterEncodingFilter;

import javax.servlet.Filter;

/**
 * Created by zhiyong.guo on 2017/8/16.
 */
@SpringBootApplication
@EnableTransactionManagement
@Import({DatabaseConfig.class})
@Controller
public class GbackSystemApplication extends SpringBootServletInitializer {
    public static void main(String[] args){
        ApplicationContext applicationContext = SpringApplication.run(GbackSystemApplication.class, args);
        SpringUtils.setApplicationContext(applicationContext);
    }

    @Bean
    public Filter characterEncodingFilter () {
        CharacterEncodingFilter characterEncodingFilter =new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);
        return characterEncodingFilter;
    }

    @RequestMapping("/")
    public String index() {
        return "？？？？？";
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(GbackSystemApplication.class);
    }

}
